<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ImageUtilitiesTest</title>

<link rel="stylesheet"
	href="http://code.jquery.com/qunit/qunit-1.15.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.15.0.js"></script>

<script src="../../../main/js/util/JavaScriptAugments.js"></script>
<script src="../../../main/js/util/Logger.js"></script>
<script src="../../../main/js/util/InputValidator.js"></script>

<script src="../../../main/js/Team.js"></script>
<script src="../../../main/js/Maneuver.js"></script>
<script src="../../../main/js/ShipAction.js"></script>
<script src="../../../main/js/Ship.js"></script>
<script src="../../../main/js/RangeRuler.js"></script>
<script src="../../../main/js/Weapon.js"></script>
<script src="../../../main/js/Pilot.js"></script>
<script src="../../../main/js/Token.js"></script>
<script src="../../../main/js/SquadBuilder.js"></script>
<script src="../../../main/js/SimpleAgent.js"></script>

<script src="../../../main/js/ui/ImageUtilities.js"></script>
<script src="../../../main/js/ui/HumanAgent.js"></script>

<script>
    var LOGGER = new Logger();
    LOGGER.setTraceEnabled(false);
    LOGGER.setDebugEnabled(false);

    QUnit
            .test(
                    "String endsWith",
                    function(assert)
                    {
                        var string = "Apple, Banana, Kiwi";
                        var key = "Banana";
                        assert.equal(string.indexOf(key), 7);
                        assert.equal(string.substr(7, key.length), key);
                        assert.equal(string.search(key), 7);
                        assert.equal(string.search(key + "$"), -1);
                        assert.equal(string.search("Kiwi"), 15);
                        assert.equal(string.search("Kiwi$"), 15);

                        var filename = "file:///Users/jmthompson/Dropbox/SoftwareDev/JavaProjects/vizzini/xwingminiaturesweb/src/resources/images/ImperialIcon24.png";
                        var expected = "file:///Users/jmthompson/Dropbox/SoftwareDev/JavaProjects/vizzini/xwingminiaturesweb/src/main/resources/images/ImperialIcon24.png";
                        filename = filename.replace("src/resources",
                                "src/main/resources");
                        assert.equal(filename, expected);
                    });

    QUnit
            .test(
                    "ImageUtilities.createTeamIconString() Imperial",
                    function(assert)
                    {
                        // Setup.
                        var imperialAgent = new SimpleAgent("Imperial Agent",
                                Team.IMPERIAL, CoreSetImperialSquadBuilder);
                        var token = new Token(Pilot.ACADEMY_PILOT,
                                imperialAgent);
                        var imageUtils = new ImageUtilities();

                        // Run.
                        var result = imageUtils.createTeamIconString(token);

                        // Verify.
                        var expected = "<img title='Imperial Faction' src='/Users/jmthompson/Dropbox/SoftwareDev/JavaProjects/vizzini/xwingminiaturesweb/src/main/resources/images/ImperialIcon24.png'/>";
                        assert.equal(result, expected);
                    });

    QUnit
            .test(
                    "ImageUtilities.createTeamIconString() Rebel",
                    function(assert)
                    {
                        // Setup.
                        var rebelAgent = new HumanAgent("Rebel Agent",
                                Team.REBEL, CoreSetRebelSquadBuilder,
                                new ImageUtilities());
                        var token = new Token(Pilot.ROOKIE_PILOT, rebelAgent);
                        var imageUtils = new ImageUtilities();

                        // Run.
                        var result = imageUtils.createTeamIconString(token);

                        // Verify.
                        var expected = "<img title='Rebel Faction' src='/Users/jmthompson/Dropbox/SoftwareDev/JavaProjects/vizzini/xwingminiaturesweb/src/main/resources/images/RebelIcon24.png'/>";
                        assert.equal(result, expected);
                    });
</script>
</head>
<body>
	<div id="qunit"></div>
</body>
</html>
